package com.mooc.yohoshop.ui.category;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.mooc.yohoshop.R;
import com.mooc.yohoshop.entity.CategoryEntity;
import com.mooc.yohoshop.imgload.ImageLoad;

import org.jetbrains.annotations.NotNull;

public class CategoryAdapter extends BaseMultiItemQuickAdapter<CategoryEntity.Values, BaseViewHolder> {

    public CategoryAdapter(){
        addItemType(CategoryEntity.TITLE, R.layout.item_category_title);
        addItemType(CategoryEntity.ITEM, R.layout.item_category);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, CategoryEntity.Values values) {
        if (values.getItemType() == CategoryEntity.TITLE){
            baseViewHolder.setText(R.id.category_title,values.category_name);
        }else {
            baseViewHolder.setText(R.id.category_content_tv,values.category_name);
            ImageLoad.loadMatch(values.category_img_path, baseViewHolder.getView(R.id.category_content_img));
        }
    }
}
